package com.glodon.paas.monitor.server.biz.service.impl;

import java.util.ArrayList;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.glodon.paas.monitor.server.biz.domain.MonitorItemSendRulesEntity;
import com.glodon.paas.monitor.server.biz.mapper.MonitorItemSendRulesMapper;
import com.glodon.paas.monitor.server.biz.service.MonitorItemSendRulesService;
import com.glodon.paas.monitor.server.dto.MonitorSendRulesDTO;
import com.glodon.paas.monitor.server.exception.MonitorException;

@Service("monitorItemSendRulesService")
public class MonitorItemSendRulesServiceImpl implements MonitorItemSendRulesService {

	@Autowired
	private MonitorItemSendRulesMapper	monitorItemSendRulesMapper;

	@Override
	public int deleteByPrimaryKey(Long id) {
		if (null == id) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"deleteByPrimaryKey ItemSendRules id is null!");
		}
		return monitorItemSendRulesMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int insert(MonitorItemSendRulesEntity record) {
		if (null == record || null == record.getItemId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID, "insert ItemSendRules record is null!");
		}
		return monitorItemSendRulesMapper.insert(record);
	}

	@Override
	public int insertSelective(MonitorItemSendRulesEntity record) {
		if (null == record || null == record.getItemId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"insertSelective ItemSendRules record is null!");
		}
		return monitorItemSendRulesMapper.insertSelective(record);
	}

	@Override
	public MonitorItemSendRulesEntity selectByPrimaryKey(Long id) {
		if (null == id) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"selectByPrimaryKey ItemSendRules id is null!");
		}
		return monitorItemSendRulesMapper.selectByPrimaryKey(id);
	}

	@Override
	public int updateByPrimaryKeySelective(MonitorItemSendRulesEntity record) {
		if (null == record || null == record.getId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"updateByPrimaryKeySelective ItemSendRules record is null!");
		}
		return monitorItemSendRulesMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByPrimaryKey(MonitorItemSendRulesEntity record) {
		if (null == record || null == record.getId()) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"updateByPrimaryKey ItemSendRules record is null!");
		}
		return monitorItemSendRulesMapper.updateByPrimaryKey(record);
	}

	@Override
	public ArrayList<MonitorSendRulesDTO> queryMonitorItemSendRules(MonitorSendRulesDTO record) {

		return monitorItemSendRulesMapper.queryMonitorItemSendRules(record);
	}

	@Override
	public MonitorItemSendRulesEntity selectByItemId(Long itemId) {
		if (null == itemId) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"selectByItemId ItemSendRules itemId is null!");
		}
		return monitorItemSendRulesMapper.selectByItemId(itemId);
	}

	@Override
	public MonitorItemSendRulesEntity selectBySendId(Long sendId) {
		if (null == sendId) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"selectByItemId ItemSendRules sendId is null!");
		}
		return monitorItemSendRulesMapper.selectBySendId(sendId);
	}

	@Override
	public MonitorItemSendRulesEntity selectByAlarmId(Long alarmId) {
		if (null == alarmId) {
			throw new MonitorException(MonitorException.ErrorCode.PARAM_INVALID,
					"selectByItemId ItemSendRules alarmId is null!");
		}
		return monitorItemSendRulesMapper.selectByAlarmId(alarmId);
	}

}
